gcc, the GNU compiler

Contents|Index|Previous|Next
`gcc`, the GNU compiler

`gcc` invokes all the necessary GNU compiler passes for you with the following utilities.

- `cpp`
The preprocessor which processes all the header files and macros that your target requires.
- `gcc`
The compiler which produces assembly language code from the processed C files. For more information, see Using GNU CC in GNUPro Compiler Tools.
- `gas`
The assembler which produces binary code from the assembly language code and puts it in an object file.
- `ld`
The linker which binds the code to addresses, links the startup file and libraries to the object file, and produces the executable binary image.

There are several machine-independent compiler switches, among which are, notably, `-fno-exceptions` (for C++), `-fritti` (for C++) and `-T` (for linking).
You have four implicit file extensions: `.c`, `.C`, `.s`, and `.S`. For more information, see Using GNU CC in GNUPro Compiler Tools.
When you compile C or C++ programs with GNU C, the compiler quietly inserts a call at the beginning of main to a GCC support subroutine called __main. Normally this is invisible—you may run into it if you want to avoid linking to the standard libraries, by specifying the compiler option, -nostdlib. Include -lgcc at the end of your compiler command line to resolve this reference. This links with the compiler support library libgcc.a. Putting it at the end of your command line ensures that you have a chance to link first with any of your own special libraries.

__main is the initialization routine for C++ constructors. Because GNU C is designed to interoperate with GNU C++, even C programs must have this call: otherwise C++ object files linked with a C main might fail.

For more information on the compiler, see Using GNU CC in GNUPro Compiler Tools.

Top|Contents|Index|Previous|Next